<div class="layui-form" lay-filter="layuiadmin-form-role" id="form">
	<div class="form-cont">
		<div class="layui-form-item verify">
		  <label class="layui-form-label">产品key</label>
		  <div class="layui-input-block">
		      <textarea type="text" class="layui-textarea" verify='require' v-model="detail.product_key" placeholder="请输入产品key"></textarea>
				<span class="hint">产品key必填</span>
		  </div>
		</div>
		<div class="layui-form-item verify">
		  <label class="layui-form-label">产品秘钥</label>
		  <div class="layui-input-block">
		      <textarea type="text" class="layui-textarea" verify='require' v-model="detail.device_name_key" placeholder="请输入产品秘钥"></textarea>
				<span class="hint">产品秘钥必填</span>
		  </div>
		</div>
	</div>
  
  <div class="form-btn" v-if="type!=3">
      <input type="button" value="保存" class="layui-btn" @click="submit">
  </div>
</div>

<script>
	layui.use(['form'], function(){
	  var $ = layui.$
	  ,form = layui.form;
	  var form=new Vue({
	  		el:'#form',
	  		data:{
	  			detail:{
					status:1
				},
				old_detail:{},
				type:layui.admin.objData.type
	  		},
	  		mounted:function() {
				//初始化
	  			if(this.type!=1) this.detail=layui.admin.objData.detail,this.old_detail=JSON.stringify(layui.admin.objData.detail);
	  		},
	  		methods:{
				radioF:function(){//radio选择
					this.detail.status==1?this.detail.status=2:this.detail.status=1;
				},
				submit:function(){
					if(layui.admin.form('#form')){
						if(this.type==2){   //编辑
							var data=layui.admin.filter(this.detail,JSON.parse(this.old_detail),'network_card_id');
							if(data){
								layui.admin.formapi('network/card_update',data);
							}
						}else{  //添加
							layui.admin.formapi('network/card_add',this.detail);
						}
					}
				}
	  		}
	  	})
	});
</script>
